package com.icecola.d1_create_thread;

import java.util.concurrent.Callable;

/*
    1.定义任务类，实现Runnable接口
 */
public class MyCallable implements Callable<String> {
    public int n;

    public MyCallable(int n) {
        this.n = n;
    }

    //2.重写runnable的call方法
    @Override
    public String call() throws Exception{
        //描述线程的执行任务
        int sum = 0;
        for (int i = 1; i <= n ; i++) {
            sum += i;
            System.out.println("i===="+i);
        }
        return "子线程求出了1到"+ n +"的和====" + sum;
    }
}
